/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package Figures;

import java.awt.Point;
import java.util.ArrayList;

/**
 *
 * @author Pablo
 */
public class Knight extends Figures{

    ArrayList<Point> movesVec;
//    int posx, posy;

   public Knight(boolean isWh, Point loc){
        isWhite=isWh;
        location = loc;
        movesVec =new ArrayList();
        movesVec.add(new Point(-2,1));
        movesVec.add(new Point(-1,2));
        movesVec.add(new Point(1,2));
        movesVec.add(new Point(2,1));

        movesVec.add(new Point(-2,-1));
        movesVec.add(new Point(-1,-2));
        movesVec.add(new Point(1,-2));
        movesVec.add(new Point(2,-1));

    }


   

    public ArrayList<Point> checkPossibleMoves(char [][] board) {
        ArrayList<Point> possibleMoves = new ArrayList();

        for(int i = 0; i<movesVec.size();i++){
            Point newLoc = new Point(location.x+movesVec.get(i).x,location.y+movesVec.get(i).y);
//            System.out.print("kon z "+location+"idzie na "+newLoc);
            if(newLoc.x>7 || newLoc.x<0 ||newLoc.y>7 || newLoc.y<0 ){ continue;} //new localisation is out of board
            if(board[newLoc.x][newLoc.y]=='0'){possibleMoves.add(newLoc);continue;} //new loc is empty

            if(this.isWhite){
                if(board[newLoc.x][newLoc.y]>=97 && board[newLoc.x][newLoc.y]<=122){possibleMoves.add(newLoc);continue;}//maybe oponents figure
                }
            else if(board[newLoc.x][newLoc.y]>=65 && board[newLoc.x][newLoc.y]<=90){possibleMoves.add(newLoc);continue;}
//            System.out.print("zajete bo jest tam "+board[newLoc.x][newLoc.y]+"\n");

        }

//        for(int c = 0;c<=7; c++){
//            for(int r = 0;r<=7; r++)System.out.print(""+board[c][r]);
//            System.out.print("\n");
//        }
        return possibleMoves;
    }
    @Override
    public int getType(){
        if(isWhite) return 78;
        else return 110;

    }
}